

package net.qiqbframework.commandhandling;

import net.qiqbframework.common.ImmutableException;
import net.qiqbframework.messaging.MessageHandler;


public class DuplicateCommandHandlerSubscriptionException extends ImmutableException {



    public DuplicateCommandHandlerSubscriptionException(String commandName,
                                                        MessageHandler<? super CommandMessage<?>> initialHandler,
                                                        MessageHandler<? super CommandMessage<?>> duplicateHandler) {
        this(String.format("A duplicate Command Handler for command [%s] has been subscribed residing in class [%s]"
                        + " that would override an identical handler in class [%s].",
                commandName,
                duplicateHandler.getTargetType().getName(),
                initialHandler.getTargetType().getName()
        ));
    }


    public DuplicateCommandHandlerSubscriptionException(String message) {
        super(message);
    }

}
